package com.lkd.controller;


import com.lkd.entity.Region;
import com.lkd.service.RegionService;
import com.lkd.vo.PageBean;
import com.lkd.vo.RegionVo;
import com.lkd.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 运营区域 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-08-20
 */
@RestController
@RequestMapping("/api/vm-service/region")
public class RegionController {

    @Autowired
    private RegionService regionService;

    //分页区域搜索
    @GetMapping("/search")
    public Result search(String name,
                         @RequestParam(defaultValue = "1")Integer pageIndex,
                         @RequestParam(defaultValue = "10")Integer pageSize){
        PageBean<RegionVo>page=regionService.search(name,pageIndex,pageSize);
        return Result.success(page);
    }

    //新增区域
    @PostMapping
    public Boolean save(@RequestBody Region region){
        boolean save = regionService.save(region);
        return save;
    }

    //修改区域
    @PutMapping
    public Boolean update(@RequestBody Region region){
        boolean update = regionService.updateById(region);
        return update;
    }


}
